#include <stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	int m = (a > b ? b : a);
	while(1) 
     {
     	if(a % m == 0 && b % m == 0)
		 {
		 	break;
		  } 
        	m--;
     	
		 }	
	
	 printf("%d\n",m);
	
	
	return 0;
 } 
